/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package be.hogent.iii.project.guigameroom;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author jef donders
 */
public class LijstCellRenderer extends JLabel implements ListCellRenderer{

    private String nickname;
    
    public LijstCellRenderer(String nickname) {
        this.nickname = nickname;
    }

    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        
        if (isSelected){
            //setBackground(list.getSelectionBackground());
            //setForeground(list.getSelectionForeground());
            setBackground(Color.BLUE);
            setForeground(Color.BLUE);
        } else {
            setBackground(list.getBackground());
            setForeground(list.getForeground());
        }
        setEnabled(list.isEnabled());
        setFont(list.getFont());
        setOpaque(false);
        
        if (((String)(value)).equals(nickname)){
            setBackground(Color.RED);
            setForeground(Color.RED);
        }
        setText("  " + (String)value);
        return this;
    }
    
    

}
